package com.ztrue.framework.core.command;

import com.ztrue.framework.infrastructure.impl.DistributeMessage;

/**
 * 命令抽象
 *
 * @author zhangw
 * @date 2016/10/27 17:29
 * @version: 1.0
 */
public abstract class Command<ATID> extends DistributeMessage implements ICommand {
    private ATID aggregateRootId;

    public Command(ATID id) {
        this.aggregateRootId = id;
    }

    /**
     * 获取聚合根字符串ID
     *
     * @return
     */
    public String getAggregateRootStringId() {
        return aggregateRootId.toString();
    }

    /**
     * 获取聚合根ID
     *
     * @return
     */
    public ATID getAggregateRootId() {
        return aggregateRootId;
    }

    /**
     * 设置聚合根ID
     *
     * @param aggregateRootId
     */
    public void setAggregateRootId(ATID aggregateRootId) {
        this.aggregateRootId = aggregateRootId;
    }

    /**
     * 获取路由密匙
     *
     * @return
     */
    @Override
    public String getRoutingKey() {
        return getAggregateRootStringId();
    }
}
